<template>
    <div class="act-box">
        <div style="height: 50px">
            <ul>
                <li>
                    <router-link to="/index">首页</router-link>
                </li>
                <li>
                    <span class="return"></span>
                    <router-link to="/activity/more">活动列表</router-link>
                </li>
                <li>
                    <span class="return"></span>
                    <router-link to="/activedetail">详情</router-link>
                </li>
            </ul>
        </div>
        <div style="padding: 10px">
            <div class="head">
                <div class="title">
                    <h2>{{activeContent.title}}</h2>
                </div>
                <div class="subtitle">
                    <div class="time">
                        <span>{{activeContent.wssbkssj}}</span>
                        至
                        <span>{{activeContent.wssbjssj}}</span>
                    </div>
                    <div class="status">
                        <span :class="activeContent.status===1?'underway':activeContent.status===2?'end':'nostart'">{{activeContent.status===1?'进行中':'结束'}}</span>
                    </div>
                </div>
            </div>
            <div class="content">
                <mavon-editor
                        style="box-shadow: none;"
                        class="md"
                        :value="activeContent.content"
                        :subfield="false"
                        defaultOpen="preview"
                        :toolbarsFlag="false"
                        :editable="false"
                        :scrollStyle="true"
                ></mavon-editor>
            </div>
            <div class="foot" v-show="footShow">
                <el-row>
                    <el-col :span="12">
                        <span>活动名称：{{activeContent.title}}</span>
                        <span>相关附件</span>
                        <p v-for="item in activeContent.annexFile" @click="downloadFile(item.filePath,item.fileName)"><a href="##">{{item.fileName}}</a></p>
                    </el-col>
                    <el-col :span="12">
                        <a href="##">{{activeContent.title}}申报须知</a>
                    </el-col>
                </el-row>

            </div>
        </div>
    </div>
</template>

<script>
    export default {
        created() {
            console.log(this.$route)
            let id= this.$route.query.id
            if(!id) {
                this.$router.go(-1)
                return
            }
            this.queryActivityDetail(id)

        },
        methods:{
            //查询活动详情
            queryActivityDetail(id){
                let that=this
                that.$http.get("/events/"+id).then(res=>{
                    that.activeContent=res.data
                })

            },
            //附件下载
            downloadFile(path,fileName) {
                this.$http.get(`/file/down?path=${path}`, {
                    responseType: 'blob',
                }).then(res => {

                    let url = window.URL.createObjectURL(res.data)
                    let link = document.createElement('a')
                    link.style.display = 'none'
                    link.href = url
                    link.setAttribute('download', fileName)
                    document.body.appendChild(link)
                    link.click()


                })

            }

        },
        data() {
            return {
                footShow: true,
                activeContent: {}
            }
        }
    }
</script>

<style scoped>
    a {
        text-decoration: none;
        color: #3A6DE4;
    }

    ul {
        float: left;
        height: 40px;
        line-height: 40px;
        font-size: 16px;
        width: 100%;
        margin-top: 20px;
    }

    li {
        color: #acacac;
        display: inline-block;
        float: left;
        padding-right: 10px;
    }

    .return {
        font-size: 16px;
    }

    .return:before {
        content: ">  ";
        font-size: 16px;
        color: #3A6DE4;
    }

    .md >>> .v-show-content {
        background-color: #ffffff !important;
    }

    /**/
    .act-box {
        width: 1200px;
        /*padding: 10px;*/
        margin: 0 auto;
    }

    .head, .content {
        text-align: center;
    }

    .head {
        width: 100%;
        /*line-height: 60px;*/
    }

    .title h2 {
        display: inline-block;
        text-align: center;
        width: 800px;
    }

    .time, .status {
        display: inline-block;
    }
    .time span{
        font-weight: 600;
    }

    .status {
        width: 120px;
        height: 40px;
    }

    .status span {
        display: inline-block;
        width: 80px;
        height: 20px;
        border-radius: 10px;
        /*background-color: #3A6DE4;*/
        color: white;
        font-size: 14px;
    }

    .content {
        width: 100%;
        padding: 10px;
    }

    .foot {
        font-size: 16px;
        width: 100%;
        height: 60px;
        padding: 10px 10px 10px 60px;
    }

    .foot span {
        margin-right: 10px;
    }

    /*
   根据状态转换class 改变背景颜色
   end:已结束背景
   nostart:未开始
   underway：进行中
   */
    .end {
        background-color: #acacac;
    }

    .nostart {
        background-color: #253FDB;
    }

    .underway {
        background-color: #19cc00;
    }

</style>
